using System.ComponentModel.DataAnnotations;
using SqlSugar;

namespace FytSoa.Domain.Car;

/// <summary>
///  抽奖，大转盘
/// </summary>
[SugarTable("cars_prize")]
public class CarsPrize:Entity
{
    /// <summary>
    /// 活动名称
    /// </summary>
    [Required]
    [StringLength(100)]
    public string Name { get; set; }
    
    /// <summary>
    /// 活动副名称
    /// </summary>
    [StringLength(100)]
    public string SubName { get; set; }

    /// <summary>
    /// 活动状态
    /// </summary>
    [Required]
    public bool Status { get; set; } = true;

    /// <summary>
    /// 中奖次数
    /// </summary>
    [Required]
    public int PickCount { get; set; } = 0;

    /// <summary>
    /// 开始时间
    /// </summary>
    [Required]
    public DateTime StartTime { get; set; } = DateTime.Now;
    
    /// <summary>
    /// 结束时间
    /// </summary>
    [Required]
    public DateTime EndTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 奖品
    /// </summary>
    [SugarColumn(IsJson = true)]
    public List<CarsPrizeInfo> Prizes { get; set; }
    
    /// <summary>
    /// 设置的抽奖次数
    /// </summary>
    [SugarColumn(IsJson = true)]
    public List<CarsPrizeUserDraw> DrawNumber { get; set; }
    
    /// <summary>
    /// 活动规则
    /// </summary>
    public string Summary { get; set; }

    /// <summary>
    /// 添加时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; }=DateTime.Now;

    /// <summary>
    /// 奖品信息
    /// </summary>
    public class CarsPrizeInfo
    {
        /// <summary>
        /// 唯一编号
        /// </summary>
        public string Id { get; set; }
        
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }
        
        /// <summary>
        /// 概率
        /// </summary>
        public int Ratio { get; set; }
        
        /// <summary>
        /// 奖品值
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 内定用户
        /// </summary>
        public List<string> Users { get; set; } = new ();
    }
    
    /// <summary>
    /// 增加抽奖数的用户
    /// </summary>
    public class CarsPrizeUserDraw
    {
        public long Id { get; set; }

        public int Number { get; set; }
    }
}